package com.shop.cloud.upms.admin.controller;

import cn.hutool.core.util.StrUtil;
import com.aliyuncs.exceptions.ClientException;
import com.shop.cloud.upms.admin.service.PhoneService;
import com.shop.cloud.common.core.util.R;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * @author
 * @date 2018/11/14
 * <p>
 * 手机验证码
 */
@RestController
@AllArgsConstructor
@RequestMapping("/phone")
@Tag(description = "phone", name = "手机相关操作管理模块")
public class PhoneController {
	private final PhoneService phoneService;

	/**
	 * 发送手机验证码
	 * @param phone
	 * @return
	 * @throws ClientException
	 */
	@PutMapping("/code")
	public R sendSmsCode(String phone, String type, String graphCode) throws ClientException {
		if(StrUtil.hasBlank(phone, type, graphCode)){
			return R.failed("参数不合法");
		}
		return phoneService.sendSmsCode(phone,type, graphCode);
	}

}
